<template>
  <div class="situation-page">
    <div class="page-header">
      <el-button class="back-button" icon="el-icon-back" @click="goback">返回</el-button>
      <div class="page-title">类别管理</div>
    </div>
    <div class="page-body">
      <div class="table-search">
        <el-form inline>
          <el-form-item label="提醒类别">
            <el-select size="mini" placeholder="请选择" >
              <el-option />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button size="mini" type="primary" @click="search">搜索</el-button>
            <el-button size="mini" @click="reset">重置</el-button>
          </el-form-item>
        </el-form>
        <el-form inline>
          <el-form-item>
            <el-button size="mini" type="primary" @click="openAdd">新增</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div class="table-box">
        <el-table
          :data="tableData"
          height="100%"
        >
          <el-table-column align="center" type="index" label="序号" width="50" />
          <el-table-column align="center" label="类别名称" min-width="200" />
          <el-table-column align="center" label="是否启用" width="120" />
          <el-table-column align="center" label="创建人" min-width="120" />
          <el-table-column align="center" label="创建时间" width="160" />
          <el-table-column align="center" label="操作" width="150">
            <template slot-scope="scope">
              <el-button type="text" size="mini" @click="openDetail(scope.row)">查看</el-button>
              <el-button type="text" size="mini" @click="openEdit(scope.row)">查看</el-button>
              <el-button
                type="text"
                size="mini"
                @click="openDelete(scope.row)"
                style="color:#F56C6C;"
              >删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <pagination
        :total="total"
        :page.sync="queryParams.pageNo"
        :limit.sync="queryParams.pageSize"
        @pagination="getData"
      />
    </div>
    <addOrEdit ref="addOrEdit" @getData="getData" />
  </div>
</template>
<script>
import addOrEdit from './addOrEdit'
export default {
  components: { addOrEdit },
  data () {
    return {
      queryParams: {
        pageNo: 1,
        pageSize: 10
      },
      total: 0,
      tableData: [],
      id: ''
    }
  },
  methods: {
    init () {
      this.queryParams.pageNo = 1
      this.getData()
    },
    openAdd () {
      this.$refs.addOrEdit.open({})
    },
    openEdit (row) {
      this.$refs.addOrEdit.open(row)
    },
    getData () {},
    goback () {
      this.$emit('goback')
    },
    search () {
      this.queryParams.pageNo = 1
      this.getData()
    },
    openDetail (row) {
      this.$refs.addOrEdit.open(row, true)
    },
    openDelete (row) {
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {})
    },
    reset () {
      this.search()
    }
  }
}
</script>
<style scoped lang="scss">
.page-header {
  display: flex;
  height: 60px;
  align-items: center;
  border-bottom: 1px solid #ddd;
  .back-button {
    margin-right: 16px;
  }
  .page-title {
    font-size: 18px;
    font-weight: 600;
  }
}
.page-body {
  padding-top: 16px;
  .table-search {
    display: flex;
    justify-content: space-between;
  }
  .table-box {
    height: calc(100vh - 280px);
    .click-span {
      cursor: pointer;
      color: #409EFF;
    }
  }
}

</style>
